#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main() {
    int a, b, t = 0;
    while (scanf("%d %d", &a, &b) != EOF)
    {
        int arr[a+b];
        for (int i = 0; i < a + b; i++)
        {
            scanf("%d", &arr[i]);
        }
        for (int j = 0; j < a + b - 1; j++)
        {
            int count = 0;
            for (int k = 0; k < a + b - j - 1; k++)
            {
                if (arr[k] > arr[k + 1])
                {
                    t = arr[k];
                    arr[k] = arr[k + 1];
                    arr[k + 1] = t;
                    count = 1;
                }
            }
            if (count == 0)
                break;
        }
        for (int y = 0; y < (a + b); y++)
            printf("%d ", arr[y]);
    }
    return 0;
}